package com.example.demobk.common;

import lombok.Data;

import java.io.Serializable;


//统一数据返回
@Data
public class AjaxResult implements Serializable {
    //状态吗
    private  Integer code;
    //信息
    private  String msg;
    //放回父类数据
    private  Object data;


    public static AjaxResult success(Object data){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setCode(200);
        ajaxResult.setMsg("");
        ajaxResult.setData(data);
       return  ajaxResult;
    }
    public static AjaxResult success(int code,Object data){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setCode(code);
        ajaxResult.setMsg("");
        ajaxResult.setData(data);
        return  ajaxResult;
    }
    public static AjaxResult success(int code,String msg,Object data){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setCode(code);
        ajaxResult.setMsg(msg);
        ajaxResult.setData(data);
        return  ajaxResult;
    }
    public static AjaxResult fail(int code,String msg){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setCode(code);
        ajaxResult.setMsg(msg);
        ajaxResult.setData(null);
        return  ajaxResult;
    }

}
